package com.metro.generator.gen;

import com.metro.utils.properties.OrderedProperties;
import com.metro.utils.properties.PropertiesHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;
import java.util.Properties;

/**
 * 代码生成器配置信息
 * Created by xk on 2018/1/29 0029.
 */
public class GeneratorProperties {
    private static Logger log = LoggerFactory.getLogger(GeneratorProperties.class);

    private static Properties properties;
    /**
     * 加载代码生成器配置文件
     * @return
     */
    public static final Properties loadGeneratorProperties(){
        if(properties != null){
            return properties;
        }
        properties = new OrderedProperties();
        String[] genConfigArr = new String[]{"generator/generator.properties"};
        try {
            PropertiesHelper.loadAllPropertiesFromClassLoader(properties, genConfigArr);
        } catch (IOException e) {
            log.error("加载配置文件出错，请检查。", e);
        }
        return properties;
    }

}
